package com.zls.controller;

import com.zls.dto.IndexDto;
import com.zls.page.Result;
import com.zls.pojo.*;
import com.zls.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("project")
public class AppController {
    @Autowired
    private StageService stageService;
    @Autowired
    private ProjectService projectService;
    @Autowired
    private SubitemService subitemService;
    @Autowired
    private IndexDto indexDto;
    @Autowired
    private ItemService itemService;
    @Autowired
    private BranchService branchService;
    @Autowired
    private TaskplanService taskplanService;
    @GetMapping("index")
    public IndexDto index(int pid){
        List<Stage> list = stageService.findByPid(pid);
        ProAndDevCon proAndDevCon = projectService.index(pid);
        indexDto.setStages(list);
        indexDto.setProAndDevCon(proAndDevCon);
        return indexDto;
    }

    @GetMapping("cname")
    public List<Subitem> cname(int pid,String cid){
        List<Subitem> byPid = subitemService.findByPid(pid);
        return byPid;
    }
    @GetMapping("item")
    public List<Item> items(String suid){
        List<Item> bySuid = itemService.findBySuid(suid);
        return bySuid;
    }
    @GetMapping("bname")
    public List<Branch> bname(int pid,String did){
        List<Branch> byPid = branchService.findByPid(pid);
        return byPid;
    }
    @GetMapping("taskplan")
    public List<Taskplan> bname(String bid){
        List<Taskplan> byPid = taskplanService.findByBid(bid);
        return byPid;
    }
}